package com.springclouddemo.service.user.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping(value = "/nacos/config/")
@RestController
//@RefreshScope//标注该类对配置进行监听，动态刷新
public class NacosConfigController {
//    @Value("${nacos.config.msg}")
//    private String msg;
//    @GetMapping("/getMsg")
//    public String getMsg() {
//        return msg;
//    }

    /**
     * nacos获取配置
     */
    @Value("${user.name}")
    private String name;
    @RequestMapping("getUsername")
    public Object getUsername() {
        System.out.println("name = " + name);
        return name;
    }

//    public Response<String> getMsg() {
//        Response<String> response = new Response<>();
//        response.setCode("1");
//        response.setMsg(msg);
//        return response;
//    }
}
